<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%
String path = request.getContextPath();
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<link rel="stylesheet" type="text/css" href="<%=path %>/static/css/css.css?1" />
<link rel="stylesheet" type="text/css" href="<%=path %>/static/jquery-ui/jquery-ui.min.css" />
<script type="text/javascript" src="<%=path %>/static/js/json2.js"></script>
<script type="text/javascript" src="<%=path %>/static/js/jquery.js"></script>
<script type="text/javascript" src="<%=path %>/static/jquery-ui/jquery-ui.min.js"></script>
<script type="text/javascript" src="<%=path %>/static/layer/layer.js"></script>
<script type="text/javascript" src="<%=path %>/static/js/gridview.js?v=1"></script>
<script type="text/javascript" src="<%=path %>/static/js/formview.js?v=1"></script>
<script type="text/javascript" src="<%=path %>/static/js/tool.js"></script>
<script type="text/javascript" src="<%=path %>/static/js/validate.js"></script>
<script type="text/javascript" src="<%=path %>/wechat/js/copy/ZeroClipboard.js"></script>
<SCRIPT type="text/javascript">
    <!--
	var gridSetting = {
			id:'QhAdverAccountGrid',
			po:"QhAdverAccount",
			title:'财务列表',
			height:'auto',
			service:"uiServices!listSimple",
			tbId:"QhAdverAccountTb",
			hideCheckbox:true,
			pageInfo: {
				records: 12,//auto表示根据容器高度自动判断
				orderby : "id desc"
			},
			fields:[
			   {	name:'id',
					hide:true
			   },{
                   name: 'type',
                   descs:"类别",
                   thstyle:"width:100px",
                   align:'center'
               },{
                   name: 'deposit',
                   descs:"存入（元）",
                   thstyle:"width:100px",
                   align:'right'
               },{
                   name: 'expend',
                   descs:"支出（元）",
                   thstyle:"width:100px",
                   align:'right'
               },
               {
                   name: 'note',
                   align:'left',
                   descs:"备注"
               },{
                   name: 'createDateTime',
                   descs:"操作时间",
                   align:'center',
                   thstyle:"width:170px",
                   type:'datetime'
               },{
                   name: 'createUser',
                   descs:"操作人",
                   align:'center',
                   thstyle:"width:160px"
               }
			]
		};
	var grid;
    $(document).ready(function(){
    	grid = new GridView("list",gridSetting,"list");
		grid.init();
		var data = [];

		grid.load({data:data});

		ajustHeight();

    });

    //-->
</SCRIPT>
</head>

<body>
<ul class=tab_nav>
  <li>
    <a class="current" href="javascript:void(0)">财务记录</a>
  </li>
</ul>
<div class="rcon2" id="head_account">
<div class="adver_account" >
   <div class="icon"></div>
   <div class="adver_right">
      账户余额<br>
      <span class="money">${sessionScope.userInfo.availFund}<span style="font-size:18px;">元</span></span>
   </div>
</div>
<div class="adver_spend" >
   <div class="icon"></div>
   <div class="adver_right">
      今天花费<br>
      <span class="money"><span id="Expend"></span><span style="font-size:18px;">元</span></span>
   </div>
</div>
</div>
<div class="contrainer">
<div class="rcon2" style="padding-bottom:0;">
<table class="search_tb">
   <tr>
      <td>
         <div style="float:left;margin-left:20px;">
             <input type="text" onclick="WdatePicker()" name="createDateTime" placeholder="开始时间" />-<input type="text" onclick="WdatePicker()" name="createDateTime" placeholder="结束时间" />
         </div>
         <input type="button" class="searchbtn" value="" id="queryBtn">
      </td>
   </tr>
</table>
</div>
<div id="formview" class="rbox1"></div>
<div id="list" class="rbox2"></div>
</div>
<script type="text/javascript" src="<%=path %>/static/js/underscore.js"></script>
<script type='text/javascript' src='<%=path %>/static/My97DatePicker/WdatePicker.js'></script>
<script type='text/javascript' src='<%=path %>/dwr/engine.js'></script>
<script type='text/javascript' src='<%=path %>/dwr/util.js'></script>
<script type='text/javascript' src='<%=path %>/dwr/interface/BaseDwr.js'></script>
<script>
    $.ajaxSetup({
        async: false
    });
    var userType="${sessionScope.userInfo.type}";
    if(userType=="A"){
       $("#head_account").hide();
    }
    $("#queryBtn").click(function(){
       var deposit = $(".ctable").find(":input[name=deposit]").val();
       var createDateTime1 = $(".ctable").find(":input[name=createDateTime]:eq(0)").val();
       var createDateTime2 = $(".ctable").find(":input[name=createDateTime]:eq(1)").val();

       var data = [];

       if(createDateTime1!==""){
          data.push({r:">=",name:'createDateTime',value:createDateTime1});
       }
       if(createDateTime2!==""){
          data.push({r:"<=",name:'createDateTime',value:createDateTime2});
       }

       grid.load({data:data});
       ajustHeight();
    });

    $.getJSON(g_path+"/public/common/getExpend.htmls",{},function(data){
        if(data.expend==null){
            $("#Expend").html("0.0");
        }
        else{
            $("#Expend").html(data.expend.toFixed(1));
        }
    });

    function afterLoad_QhAdverAccountTb(){
        var deposit=0,expend=0;
        $(".rcon2 .mtable tbody tr").each(function(){
            var d=$(this).find("td[name=deposit]").text();
            var e=$(this).find("td[name=expend]").text();
            if(d!=""){
                deposit+=parseFloat($(this).find("td[name=deposit]").text());
            }
            if(e!=""){
                expend+=parseFloat($(this).find("td[name=expend]").text());
            }
            $createUser=$(this).find("td[name=createUser]");
            $.getJSON(g_path+"/public/common/getAdverName.htmls",{uid:$createUser.text()},function(data){
                $createUser.text(data.name);
            });
        });
        var html="<tr><td></td><td style='text-align:center'>本页总计</td><td style='text-align:right'>"+deposit+"</td><td style='text-align:right'>"+expend+"</td><td></td><td></td><td></td></tr>";
        $("#QhAdverAccountTb tbody").append(html);
    }

</script>
</body>
</html>